<?php
namespace app\index\controller;


use app\model\Enter as EnterModel;

class EnterController extends Base {

    public function auth()
    {
        $data = [
            'errno' => 400,
            'data' => UID()
        ];
        return $this->json(['data' => $data]);

    }

    public function is_auth()
    {
        $fields =  json_decode(input('post.registerfield'), true);
        $insert = [];
        foreach ($fields as $key => $value){
            if($value['viewmingcheng'] == '企业名称'){
                $insert['title'] = $value['fieldsvalue'];
            }
            if($value['viewmingcheng'] == '联系人'){
                $insert['contacts'] = $value['fieldsvalue'];
            }
            if($value['viewmingcheng'] == '联系电话'){
                $insert['mobile'] = $value['fieldsvalue'];
            }
            if($value['viewmingcheng'] == '营业执照'){
                $insert['business'] = $value['fieldsvalue'];
            }
        }
        $insert['uid'] = UID();
        $count = EnterModel::where(['id'=>UID(), 'status'=>1, 'statue'=>0])->count();
        if($count < 1){
            EnterModel::create($insert);
        }
        $data['fields'] = $insert;
        return $this->json(['data' => $data]);
    }




}